package com.etc;

import com.alibaba.druid.pool.DruidDataSource;
import org.activiti.spring.boot.SecurityAutoConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.sql.ResultSet;
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@MapperScans({@MapperScan("com.etc.dao"), @MapperScan("com.etc.shiro.mapper")})
public class TestMain1 implements CommandLineRunner {
    public static void main(String[] args) {
//        Student stu = new Student();
//
//        stu.setSname("aaa");
//        System.out.println(stu);
//
//        Student1 stu1 = new Student1();
//        stu1.setSname("bbb");
//        System.out.println(stu1);

        SpringApplication.run(TestMain1.class, args);
    }

    // 自动注入：  从容器中拿出DruidDataSource子类 放到属性上
    // DI:  IOC控制反转--DI依赖注入
    @Autowired
    DruidDataSource dataSource;
    @Override
    public void run(String... args) throws Exception {
        System.out.println("-------aa----------");
        System.out.println("--------bb---------");
        System.out.println("-------------------");
        System.out.println("-------------------");
        System.out.println("-------------------");
        System.out.println(dataSource);
        ResultSet rs = dataSource.getConnection().createStatement().executeQuery("SELECT * FROM emp");
                rs.next();
        System.out.println(rs.getObject(1));
        System.out.println(rs.getObject(2));
        System.out.println(rs.getObject(3));

    }
}
